<template>
	<view class="page">
		<view class="page-wrap">


			<view class="page-ctx">
				<view class="user-box flex">
					<view class="avatar-box">
						<image :src="mix_user_avatar" mode=""></image>
					</view>
					<view class="info-box">
						<view class="nick">
							{{mix_user_nick}}
						</view>
						<view class="phone">
							{{mix_user_phone}}
						</view>
					</view>
				</view>

				<view class="tip">
					微信扫码，进入小程序
				</view>

				<view class="share-wrap">
					<!-- 分享海报 -->
					<l-painter
						css="width: 638rpx;padding: 40rpx 24rpx;border-radius: 24rpx; margin: 0 auto; background: #FFFFFF;box-sizing: border-box; "
						@fail="fail" pathType="url" ref="share_poster">
						<l-painter-view css="background:#FFFFFF;">

							<l-painter-view css="background:#ffffff; text-align:left;">
								<l-painter-text text="LCCOL LIFE"
									css="text-align:center;font-size: 40rpx;font-weight: bold;color: #000000;">
								</l-painter-text>
							</l-painter-view>
							<l-painter-view css="background:#ffffff;margin-top:0rpx;text-align:left;">
								<l-painter-text text="乐辰生活" css="text-align:left;font-size: 40rpx;color: #000000;">
								</l-painter-text>
							</l-painter-view>


							<l-painter-view css="background: #F8F8F8;;margin-top:32rpx;padding: 78rpx 0;text-align:center;">
								<l-painter-image :src="image_logo" css="width:202rpx;height:188rpx;display:block;margin:0 auto;" />
								<l-painter-text text="LCCOL LIFE  乐辰生活"
									css="margin-top: 52rpx;text-align:center;font-size: 28rpx;color: #A8ADB7;font-weight: 400;">
								</l-painter-text>
								<l-painter-view
									css="position:relative;width:296rpx;height:264rpx;margin:0 auto;margin-top:76rpx;dispaly:flex; justify-content: center; align-items: center;">
									<l-painter-view
										css="position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:192rpx;height:192rpx">
										<l-painter-image :src="image_code" css="display:block;width:192rpx;height:192rpx;margin:0 auto;" />
									</l-painter-view>
									
								</l-painter-view>
							</l-painter-view>
							<!--  -->
						</l-painter-view>
					</l-painter>
					<!-- 分享海报 -->
				</view>

				<view class="foot-btns">
					<!-- 	<view class="btn flex-center" @click="share_poster_save()">
						保存
					</view> -->
					<button open-type="share" class="btn flex-center">
						分享链接
					</button>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// image_logo: require('@/static/fans/invite-logo.png'),
				image_logo: '',
				image_code_wrap: require('@/static/fans/invite-code-wrap.png'),
				image_code: '',
				// image_code_demo: require('@/static/fans/code-demo.png'),
			}
		},
		computed: {

		},
		onLoad(options) {
			this.image_code = this.getAssets(`@/static/static-online/fans/invite-logo.png`);
			this.queryUserPoster();
		},

		onShow() {
			this.$log('配置', {
				...this.vuex_config
			})
		},
		methods: {
			queryUserPoster() {
				this.$api({
					url: '/service.php',
					method: 'get',
					data: {
						action: 'users_shareInfo',
					},
				}).then(res => {
					if (res.code == 200) {
						this.image_code = res.data.code
					}
				})
			},

			share_poster_save() {
				this.$refs.share_poster.canvasToTempFilePathSync({
					fileType: 'jpg',
					quality: 1,
					success: (res) => {
						console.log(res.tempFilePath)
						this.picture2 = res.tempFilePath

						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success: function() {
								uni.showToast({
									title: '保存成功',
									duration: 4000
								})
							},
							fail() {
								// uni.hideLoading()
							}
						});
					}
				})
			},
		}
	}
</script>


<style lang="less" scoped>
	.page {
		.page-wrap {
			padding: 64rpx 32rpx;
			height: 100%;
			box-sizing: border-box;
			background: #FFFFFF;
		}
	}





	.page-ctx {
		padding: 48rpx 24rpx;
		background: #99A6AF;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
	}

	.user-box {
		.avatar-box {
			width: 104rpx;
			height: 104rpx;
			border-radius: 50%;
			overflow: hidden;

			image {
				width: 104rpx;
				height: 104rpx;
			}
		}

		.info-box {
			padding-left: 32rpx;

			.nick {
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #FFFFFF;
			}

			.phone {
				margin-top: 10rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #FFFFFF;
			}
		}
	}

	.tip {
		margin-top: 18rpx;
		margin-bottom: 42rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #FFFFFF;
	}




	.share-wrap {
		box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(0, 0, 0, 0.08);
		border-radius: 16rpx 16rpx 16rpx 16rpx;

		margin-bottom: 88rpx;
	}



	.foot-btns {
		margin-top: 88rpx;

		.btn {
			height: 88rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(0, 0, 0, 0.08);
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #333333;
		}
	}
</style>